//
// Delaunay Triangulation
//
// Homework of CG lesson (Fall 2009) in Tsinghua University.
// All rights reserved.
//

#pragma once

/**
 * class for 2d vector.
 */
class Vector2d
{
// public constructors & destructor
public:
    /**
     * Sets all coordinate values to 0.0 by default.
     */
    Vector2d(void);
    /**
     * Sets x, y coordinate values with @c tx and @c ty.
     */
    Vector2d(double tx, double ty);
    /**
     * Copy constructor.
     */
    Vector2d(const Vector2d& vect);

// public member functions
public:
    /**
     * Gets the norm of vector.
     */
	double norm(void) const;
    /**
     * Returns the square norm of vector.
     */
    double squareNorm(void) const;
    /**
     * Normalizes self.
     * @return true if it is nonzero vector, or else @return false.
     */
	bool normalize(void);
    /**
     * Operator +.
     */
	Vector2d operator+(const Vector2d& vect) const;
    /**
     * Operator +=.
     */
    Vector2d& operator+=(const Vector2d& vect);
    /**
     * Operator -.
     */
	Vector2d operator-(const Vector2d& vect) const;
    /**
     * Operator -=.
     */
    Vector2d& operator-=(const Vector2d& vect);
    /**
     * Operator *.
     */
	Vector2d operator*(double c) const;
    /**
     * Operator *=.
     */
    Vector2d& operator*=(double c);
    /**
     * Returns the dot product of two <code>Vector2d</code>s.
     */
	double dot(const Vector2d& vect);

// public data members
public:
    double x;
    double y;
};
